package tcp;
import java.io.IOException;
import java.util.HashMap;

/**
 * Tcp版的翻译服务器端
 */

public class TcpDictServer extends TcpEchoServer{

    private HashMap<String, String> hashMap = new HashMap<>();

    public TcpDictServer(int port) throws IOException {
        super(port);

        hashMap.put("cat", "小猫");
        hashMap.put("dog", "小狗");
        hashMap.put("pig", "小猪");
    }

    @Override
    public String process(String request){
        return hashMap.getOrDefault(request, "该词无法翻译");
    }

    public static void main(String[] args) throws IOException {
        TcpEchoServer tcpEchoServer = new TcpDictServer(9090);
        tcpEchoServer.start();
    }
}